package com.lianrui.app.user.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.springframework.stereotype.Repository;

import com.lianrui.app.user.domian.User;
import com.lianrui.app.user.vos.UserPage;
import com.lianrui.commons.exception.BusinessException;
import com.lianrui.core.IDao;

/**
 * 功能描述：用户数据接口
 *
 * @author LJQ
 *
 * 2015年12月18日 上午9:56:55
 */
@Repository(value = "userDao")
public interface IUserDao extends IDao<UserPage, User, Integer>{
	
	@Insert("insert into user(name) values (#{name})")
	@SelectKey(statement="select max(id) from user", keyProperty="id", before=false, resultType=Integer.class)
	public void add(User user) throws BusinessException;
	
	@Delete("delete from user where id in (#{id})")
	public void delete(Integer... id) throws BusinessException;
	
	@Select("select * from user where id = #{id}")
	public User unique(Integer id) throws BusinessException;
	
	@Select("select count(*) from user")
	public int count() throws BusinessException;
}
